//
//  HomeViewController.m
//  HomeDecoration
//
//  Created by xalo on 16/2/26.
//  Copyright © 2016年 美家项目组. All rights reserved.
//

#import "HomeViewController.h"
#import "GoodHomeLayout.h"
#import "GoodHomeCollectionViewCell.h"
#import "HomeHelper.h"
#import "HomeModel.h"
<<<<<<< HEAD
#import "AllGoodHomeController.h"

@interface HomeViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (strong, nonatomic) IBOutlet UICollectionView *homeCollectionView;
@property (strong, nonatomic) IBOutlet UILabel *goodHomeTitle;
@property (strong, nonatomic) IBOutlet UILabel *goodHomeDescripition;

=======

@interface HomeViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (strong, nonatomic) IBOutlet UICollectionView *homeCollectionView;
>>>>>>> 1975201db659495b68bacbc5bddd203a4c2ada18

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.homeCollectionView.dataSource=self;
    self.homeCollectionView.delegate=self;
    self.homeCollectionView.collectionViewLayout=[[GoodHomeLayout alloc] init];
<<<<<<< HEAD
    
=======
>>>>>>> 1975201db659495b68bacbc5bddd203a4c2ada18
    //网络请求获取数据
    
    [[HomeHelper sharedHomeHelper] fetchDataWithUrl:kHome block:^{
        [self.homeCollectionView reloadData];
    }];
<<<<<<< HEAD
    //左导航
    [self setLeftButton];
=======
>>>>>>> 1975201db659495b68bacbc5bddd203a4c2ada18
    
}
//设置导航栏左按钮
-(void)setLeftButton
{
<<<<<<< HEAD
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"所有" style:(UIBarButtonItemStylePlain) target:self action:@selector(enterToAllGoodHome)];
    self.navigationController.navigationBar.tintColor=[UIColor blackColor];
    

}
-(void)enterToAllGoodHome
{
    UIStoryboard *mainSB=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    AllGoodHomeController *goodHomeVC=[mainSB instantiateViewControllerWithIdentifier:@"allGoodHomeVC"];

    [self.navigationController pushViewController:goodHomeVC animated:YES];
    
    
}
//给homeCollectionView添加边缘滑动手势
-(void)addGestureRecognizer
{
  
}
=======
  

}

>>>>>>> 1975201db659495b68bacbc5bddd203a4c2ada18
//代理方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return [[HomeHelper sharedHomeHelper] homeModelArrayCount];
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    GoodHomeCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"GoodHomeCell" forIndexPath:indexPath];
    HomeModel *model=[[HomeHelper sharedHomeHelper] returnHomeModelWithIndex:indexPath.item];
<<<<<<< HEAD
    
    self.goodHomeTitle.text=model.title;
    self.goodHomeDescripition.text=model.desc;
=======
>>>>>>> 1975201db659495b68bacbc5bddd203a4c2ada18
    [cell setContentWithModel:model];
    
    return cell;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
